Torsten’s AmigaDOS Shell Commands User’s Reference Manual

\begin{matrix}c \\ ◯ \end{matrix} 1993 Torsten Poulin^{1}

Revised October 22, 1993 Printed October 22, 1993

1Everyone is permitted to copy and distribute verbatim copies of this document, but changing it is not allowed.

Contents

1 About the package 2 1.1 Copying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 About the source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 Caveat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.5 Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Command Specifications 5 2.1 About the specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Common(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Compare(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Concat(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Copyright(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Count(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 DirTree(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Find(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Head(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Lower(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Prepare(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 SCD(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Split(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 SplitName(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Tee(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 TestBits(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 TimeCom(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Unique(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Usage(V37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Chapter 1

About the package

“I said it in Hebrew — I said it in Dutch —

I said it in German and Greek:

But I wholly forgot (and it vexes me much) That English is what you speak!”

— LEWIS CARROLL, The Hunting of the Snark (1876)

1.1 Copying

The programs described in this manual are free software; you can redistribute them and/or modify them under the terms of the GNU General Public Licence as published by the Free Software Foundation; either version 2 of the Licence, or (at your option) any later version.

These programs are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence for more details.

You should have received a copy of the GNU General Public Licence along with these programs; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Except where stated otherwise, all the programs and other files included in this distribution are Copyright \begin{matrix}c \\ ◯ \end{matrix}1989, 1990, 1991, 1992, 1993 Torsten Poulin.

The copyright messages in the commands can be displayed by typing the following command:

    1> COPYRIGHT command

copyright is one of the commands included in this distribution.

Torsten’s AmigaDOS Shell Commands

1.2 Introduction

I wrote the commands described in this manual simply because I felt they would be useful to have around. They are meant to be a supplement to the ones supplied with the operating system, not as a replacement for them. They are generally able to read from their default input, an ability sadly missing from the standard AmigaDOS commands making them rather awkward to use with pipes.

At present Commodore’s shell does not support pipes, but some third party shells do. I recommend that you purchase William Hawes’ excellent WShell 2.0. It has pipes, the backtick stuff is improved, and it also has better ARexx support, to name but a few things.

If you don’t want to get a new shell or simply can’t afford it, I will suggest that you get hold of Andy Finkel’s “ShellTools” from Fish disk 673:

Four small useful programs. pipe provides command line pipes, history allows the history to be loaded, saved, and listed, foreach is a fancy loop and variable expansion command, and recorder saves all console input and output in a file. Binary only.

Actually you should get them even if you have WShell or something equivalent, because Mr. Finkel’s pipe command addresses the problem of the AmigaDOS commands that can’t read their default input (and really pathological cases, like sort, that can’t write to their default output either), and his foreach command opens a whole new world of possibilities with shell scripts.

All the commands are ‘pure’ and can be made resident. If the p-flags are not set when you recieve the package you can set them with the protect command.

If you have any questions or bug reports, you can send them to me at the following address:

Torsten Poulin

Banebrinken 99, 2, -77 DK–2400 København NV Denmark Phone: +45 39663111

1.3 About the source code

The source code for the commands may look a bit unusual. The reason for this is that I wanted the resulting executables to be both relatively small and “pure”, just like Commodore’s, without resorting to assembler. Therefore they are written to be linked without any startup code and they don’t use global variables, only constants. To emphasize the lack of startup code, there are no main() functions. Instead each program starts with a function, that has to be the first one, called entrypoint() where execution will begin. Add the built-in ANSI C string functions and the #pragma libcall and #pragma syscall capability of SAS/C 5.10 and you end up with little programs that don’t have to be linked with anything, apart from the small linker library containing functions common to several of the commands (except find, which is linked with SAS lcr.lib and amiga.lib because it calls setjmp(), longjmp(), and

amiga.lib/SetRexxVar()).

Even though the use of #pragmas make the source code somewhat SAS/C specific (global library base pointers are unnecessary), it shouldn’t be too difficult to port it to other compilers like DICE or GNU C. Should you decide to port it, please note that the #pragma syscalls have made it unnecessary for me to set the exec.library base pointer, SysBase, at all.

1.4 Caveat

If you use release 2.1 (V38) or 3.x (V39) of the operating system, please note that the commands included in this release were written for OS 2.04 (V37). The fact that they are blissfully unaware of the existence of the locale.library doesn’t mean that they don’t become fairly localized. This is because locale.library patches a number of system date and character comparison functions to match the current locale specified by the user. This is arguably a good thing, though it does mean that you will have to specify some arguments, like the parameters of the since and upto functions used by find, in the currently selected language (e.g., assuming it is Danish, ‘i dag’, ‘i går’, ‘fremtid’, ‘mandag’, etc. for ‘today’, ‘yesterday’, ‘future’, ‘monday’, etc.

1.5 Acknowledgement

The wording of the following manual pages owes quite a lot to various AmigaDOS and unix manuals.

Chapter 2

Command Specifications

2.1 About the specifications

In this chapter, each command is explained following a standard outline:

FORMAT All the arguments and options the command accepts. Arguments that must be provided are printed like argument. Optional arguments and keywords are surrounded by square brackets, []. Items that can be given once or repeated any number of times are surrounded by braces, like {argument}. Finally, a vertical bar, |, is used to separate items of which you can choose only one.

Please note that the brackets are not to be typed as part of the command.

TEMPLATE A reminder of the command’s format. If you type a command followed by a question mark, the template will appear on the screen.

PURPOSE A brief explanation of the command’s function.

SPECIFICATION A concise description of the command and all of its arguments.

EXAMPLE(S)

One or more examples showing the use of the command. The command and any screen output are indented from the main text. A generic 1> prompt indicates what should be typed at the shell prompt.

SEE ALSO A list of related commands. This can include the standard AmigaDOS commands documented in for example “The AmigaDOS Manual”, 3rd. Edition, Bantam Books, 1991 and the “Using The System Software” manual distributed with Release 2.04.

UNIX EQUIVALENT Simply tells you where I got the inspiration from. It points you to the relevant entry in the unix system v manuals.

There may be other fields as well, but they are pretty self-explanatory.

For a more complete description of how to use the templates and how to use patterns to match file names, please refer to the aforementioned books on AmigaDOS.

Common(V37)  (Torsten’s AmigaDOS Shell Commands)  Common(V37)

FORMAT

COMMON [FILE1] file1 [[FILE2] file2 ] [-1] [-2] [-3]

TEMPLATE

FILE1/A,FILE2,-1/S,-2/S,-3/S

PURPOSE

To select or reject lines common to two sorted files.

SPECIFICATION

The command common reads file1 and file2 , which should be ordered in the collating sequence of sort, and produces a three-column output: lines only in file1 ; lines only in file2 ; and lines in both files. Switches -1, -2, or -3 suppress printing of the corresponding column. Thus common -1 -2 prints only the lines common to the two files; common -2 -3 prints only the lines in the first file but not in the second; common -1 -2 -3 is a no-op. If file2 is not given, the default input will be used.

SEE ALSO

compare, prepare, sort, unique

UNIX EQUIVALENT

comm(BU CMD)

Compare(V37)  (Torsten’s AmigaDOS Shell Commands)  Compare(V37)

FORMAT

COMPARE [[FILE1] file] [[FILE2] file] [[SKIP1] n] [[SKIP2] n] [QUIET]

TEMPLATE

FILE1,FILE2,SKIP1/N,SKIP2/N,QUIET/S

PURPOSE

To perform a byte-by-byte comparison of two files.

SPECIFICATION

compare compares the two files given by file1 and file2. If only one file is given, the default input is used for the other. It is an error if both file1 and file2 are omitted. compare makes no comment if the files are the same; if they differ, it reports the byte (in both decimal and hex) and line number at which the difference occured, or, that one file is an initial subsequence of the other. skip1 and skip2 are initial decimal byte offsets into file1 and file2 respectively. If the quiet switch is used, compare will print nothing for differing files; it will set the condition flag only. quiet does not suppress the printing of error messages. The condition flag, RC, is set to 0 for identical files, 5 (WARN) for different files, and 10 (ERROR) for bogus arguments like inaccessible files.

EXAMPLE

If you want to express an offset in octal or hexadecimal, you can use EVAL:

    1> COMPARE Foo Bar `EVAL 0x1FE`

SEE ALSO

common

UNIX EQUIVALENT

cmp(BU CMD)

Concat(V37)  (Torsten’s AmigaDOS Shell Commands)  Concat(V37)

FORMAT

CONCAT [[FROM] {file|pattern}] [AS|TO name] [SORT] [VISIBLE [TABS] [EOL]]

TEMPLATE

FROM/M,AS=TO/K,SORT/S,VISIBLE/S,TABS/S,EOL/S

PURPOSE

To concatenate and print files.

SPECIFICATION

concat reads each of the specified from files and writes it to the destination specified by the to option. If no from option is given concat reads from its default input; likewise if no to option is specified it writes to its default output.

The following switches apply to concat.

sort The from files are read in alphabetical order. Useful when concatenating files split with split.

visible Causes non-printing characters (with the exception of tabs and new-lines) to be printed visibly. Control characters are printed as ∧X (control-x); the DEL character (hex 0x7d) is printed as ∧?. Non-ASCII characters (with the high bit set) are printed as M-x, where x is the character specified by the seven low order bits.

When used with the visible switch, the following switches may be used.

tabs

Causes tabs to be printed as ∧I’s. eol

Causes a $ character to be printed at the end of each line (prior to the new-line).

The tabs and eol switches are ignored if the visible switch is not specified.

SEE ALSO

copy, join, more, split, type

Copyright(V37)  (Torsten’s AmigaDOS Shell Commands)  Copyright(V37)

FORMAT

COPYRIGHT [FILE] {file|pattern}

TEMPLATE

FILE/M/A

PURPOSE

To find and print embedded copyright messages.

SPECIFICATION

copyright finds embedded copyright messages in the given files. The embedded messages have the following format: $COPYRIGHT: message string $|NUL They are terminated by either a NUL byte (0x0) or another $ character. Thus it is possible to output multi-line messages if you use something like

char msg[]="$COPYRIGHT: \begin{matrix}c \\ ◯ \end{matrix} 19xx J. Random Hacker\nThis is...$";

in your source code. Leading spaces in the message are skipped. It is recommended that you always use the terminating $ character. The NUL byte is accepted mainly to be compatible with a similar copyright string used in software like the XFH-Handler by Kristian Nielsen (bombadil@diku.dk). No diagnostic is printed if a copyright message can’t be found.

SEE ALSO

version

Count(V37)  (Torsten’s AmigaDOS Shell Commands)  Count(V37)

FORMAT

COUNT [[FROM] {name|pattern}] [LINES] [WORDS] [BYTES|CHARS]

TEMPLATE

FROM/M,LINES/S,WORDS/S,BYTES=CHARS/S

PURPOSE

To count lines, words, and characters.

SPECIFICATION

count counts lines, words, and characters in the named files, or in the default input if no names appear. It also keeps a total count for all named files. A word is a maximal string of characters delimited by spaces, tabs, or new-lines. The switches lines, words, and chars may be used to specify that a subset of lines, words, and characters are to be reported. If no switches are given count defaults to all of them. When names are specified on the command line, they will be printed along with the counts.

DirTree(V37)  (Torsten’s AmigaDOS Shell Commands)  DirTree(V37)

FORMAT

DIRTREE [[DIR] {directory}] [NOHEAD] [FILES]

TEMPLATE

DIR/M,NOHEAD/S,FILES/S

PURPOSE

To show directory hierarchy trees.

SPECIFICATION

dirtree shows the directory hierarchy trees for each of the specified directories or volumes. If no names are given, the current directory is used. The nohead switch suppresses the printing of the header information. Files are only included in the listing, if the files switch is used. dirtree will neither follow soft nor hard links; it will, however, append <sl> or <hl> to their names.

Pressing Ctrl-C aborts the directory tree listing.

EXAMPLE

    1> DIRTREE ram:
    Directory tree ram: on Saturday 22-Feb-92
    Ram Disk
    +---Clipboards
    +---env
    | `---sys

|

    `---T

BUGS

Soft links causes weird behaviour.

SEE ALSO

dir, list

Find(V37)  (Torsten’s AmigaDOS Shell Commands)  Find(V37)

FORMAT

FIND [DIR] directory [DEPTH] [EXPRESSION] expression

TEMPLATE

DIR/A,DEPTH/S,EXPRESSION/F/A

PURPOSE

To find files and directories.

SPECIFICATION

find recursively descends the directory hierarchy for directory seeking files and directories that match the expression written using the functions given below. In the descriptions, the argument n is used as a decimal integer. gt n means greater than n, lt n means less than n, and eq n, or simply n, means exactly n. The depth switch causes the descent of the directory hierarchy to be done so that all entries in a directory are acted on before the directory itself. The function and operator names are not case sensitive.

The expression is made up of:

comment pattern True if pattern matches the comment attached to the current name.

days [gt|lt|eq] n True if the file or directory has been modified in n days

exec commmand True if the executed command returns a zero value as its return code. A command line containing whitespace must either have the whitespace escaped, or be surrounded by quotes. A command argument {} is replaced by the current name (with its relative path).

execok command As exec except that the generated command line is printed with a question mark, and is executed only if the user responds by typing a y.

flags flags True if flags matches the protection bits of the current name. The flags argument is a string of letters representing the protection bits:

r The file can be read.

w The file can be written to.

e The file is an executable program. d The file can be deleted. s The file is a script. p The file can be made resident. a The file has been archived.

If a letter is preceded by a ‘-’, it means that in order to match, the corresponding file bit must not be set. Unspecified bits are ignored in the comparison. Whitespace is not allowed in flags.

lformat fmtstring Always true; prints fmtstring replacing occurences of %N with the name of the object, %R with its relative path, %L with its length in bytes (this is only useful for file type objects), and %C with any attached comments. To print a % character use %%.

name pattern True if pattern matches the current name.

print Always true; causes the current name to be printed (with its relative path).

prune Always true. Has the side effect of pruning the search tree at the current name. Necessary if the depth switch isn’t used and the directory currently being matched is deleted.

rexx string-file True if the ARexx string-file returns with a zero return code. An Arexx stringfile is a one line program given directly on the command line. The ARexx interface supports one command: getattr stem., where stem. (remember the trailing dot) is the name of the ARexx stem variable the information about the current name is to be placed in. The resulting compound symbol will have the following nodes:

.name

The current name without its path. .relname

The current name with its relative path. .fullname

The current name with its full path. .comment

The optional attached comment or an empty string. .type

The type: file, linkfile, dir, linkdir, softlink or unknown. .size

The size in bytes. Only meaningful for files.

.day

The name of the day of the last modification. .date

The last modification date in the standard Amiga format. .time

The last modification time in the standard Amiga format. .days, .mins, and .ticks

The time of the last modification expressed as the number of days since January 1, 1978, the number of minutes past midnight, and the number of “ticks” past the minute.

since date True if the file or directory has been modified on or after date. The format for date is either dd-mmm-yy or one of tomorrow, today, yesterday, monday, tuesday, wednesday, thursday, friday, saturday, or sunday.

size [gt|lt|eq] n True if the file is n bytes long. Always false if the current name is not a (hard link to a) file.

type type True if the type of the filesystem object is type, where type is one of file, linkfile, dir, linkdir, or softlink for file, hard link to file, directory, hard link to directory, or soft link to a file or directory, respectively.

upto date

True if the file or directory has been modified on or before date. {expression}

True if the expression inside the braces is true.

The functions may be combined using the following operators:

not

The negation of a function. and

Concatenation of functions. The keyword and is optional, as it is implied by the juxtaposition of two functions.

or Alternation of functions.

find uses ‘*’ as an escape character to remove the special meaning of characters, so to get an ‘*’, you will have to enter ‘**’. The special escape sequences ‘*N’ and ‘*T’ mean the new-line and tab characters, respectively. Escaping works everywhere in the expression, not just inside double quotes. You can even escape the space character:

exec delete* *{*} gives exactly the same result as exec "delete {}".

EXAMPLES

To remove all files ending in ! or .bak:

    1> FIND SYS: {NAME #?! OR NAME #?.bak} EXEC "DELETE {}"

To find all files ending in .c on DH0: without searching the sub-tree starting at the directory “user”:

    1> FIND DH0: {TYPE DIR NAME user PRUNE} OR NAME #?.c PRINT

DIAGNOSTICS

Should really be more informative. ARexx is inaccessible: Either the ARexx interpreter (rexxmast) isn’t running or find was unable to create its communications port. find will not complain about this if the rexx function isn’t used. Thus it is possible to use find on a system without Arexx.

BUGS

It may take several Ctrl-C’s to halt find when exec, execok, or rexx is used. Specifying the depth switch is an effective way of defeating the purpose of prune. That may change in the future. (If you can think of a good reason for making depth a function, as in unix find, instead of a command line switch, please send me a post-card explaining why).

SEE ALSO

list, rx, search The section on ARexx in the “Using The System Software” manual.

UNIX EQUIVALENT

find(BU CMD)

Head(V37)  (Torsten’s AmigaDOS Shell Commands)  Head(V37)

FORMAT

HEAD [[FROM] {file|pattern}] [TO file] [NUM|NUMBER n]

TEMPLATE

FROM/M,TO/K,NUM=NUMBER/N/K

PURPOSE

To display first few lines of specified files.

SPECIFICATION

head copies the first number lines of each from file to the default output or the to file if one is given. If no from files are given, head copies lines from the default input. The default number of lines is 10. When more than one file is specified, the start of each file looks like:

    ==>filename<==

EXAMPLE

A way to display a set of short files, identifying each one, is:

    1> HEAD filename1 filename2 NUMBER 9999

SEE ALSO

concat, tail, type

UNIX EQUIVALENT

head(BU CMD)

Lower(V37)  (Torsten’s AmigaDOS Shell Commands)  Lower(V37)

FORMAT

LOWER [BY value] [STACK size] [COMMAND] command line

TEMPLATE

BY/K/N,STACK/K/N,COMMAND/F/A

PURPOSE

To run a command at a nice, possibly lower, priority.

SPECIFICATION

Since the Amiga is multitasking, it uses priority numbers to determine the order in which current tasks should be serviced. Normally, most tasks have a priority of 0, and the time and instruction cycles of the CPU are divided equally among them. lower executes the specified command line with the priority lowered by value. If no by option is specified a default value of 1 is used. If a negative value is specified the priority will be raised instead. The resulting priority will be between -128 and +10. This is enforced silently. The stack option sets the stack size of the command to be executed. Default is to use the current stack size. The command line is any valid shell command line; i.e. it is possible to use redirection, aliases, resident commands etc. lower leaves the value of the executed command in the condition flags RC and Result2. Ctrl-C, D, E, and F are sent to the executed command.

EXAMPLE

To print the file Text at lower priority, type:

    1> LOWER COPY Text TO PRT:

SEE ALSO

changetaskpri, stack, status

UNIX EQUIVALENT

nice(AS CMD)

Prepare(V37)  (Torsten’s AmigaDOS Shell Commands)  Prepare(V37)

FORMAT

PREPARE [[FROM] file|pattern] [TO file] [TOLOWER|TOUPPER] [HYPHEN]

TEMPLATE

FROM/M,TO/K,TOLOWER/S,TOUPPER/S,HYPHEN/S

PURPOSE

To extract the words of files and print them one per line.

SPECIFICATION

prepare extracts the words of the given files, or the default input, and prints them, one per line, to the default output, or to the destination specified by the to argument. A word is a maximal string of letters from the ISO Latin 1 character set. A compound made with hyphens, ‘-’, is split up into its constituent parts unless the hyphen switch is specified. In-word apostrophes are recognized, so words like ‘doesn’t’ etc. are printed correctly. If the tolower or the toupper switch is given, the characters are folded to lower or upper case respectively. It is an error if both are given.

prepare can, for example, be used with sort and unique to produce word lists.

EXAMPLE

It is possible to make a “poor man’s” spelling checker (should be entered as one line):

    1> PIPE PREPARE foo TOLOWER | SORT IN: OUT: | UNIQUE
            | COMMON dict -1 -3

where ‘foo’ is the file to be checked, and ‘dict’ is a sorted dictionary of words in lower case. The words reported to the default output are not in the dictionary, and are therefore possible spelling mistakes. This example assumes you have Andy Finkel’s pipe command. Use temporary files if you don’t.

SCD(V37)  (Torsten’s AmigaDOS Shell Commands)  SCD(V37)

FORMAT

SCD [DIR] name|pattern

TEMPLATE

DIR/A

PURPOSE

To change directory in a short and convenient way.

SPECIFICATION

scd attemps to locate the specified directory in a lookup table. If it cannot be found, a “Can’t find name” error message is displayed. If there is more than one matching directory, a screen allowing the user to select the correct one will pop up. Pressing ‘s’ will move to the next name, ‘S’ to the previous. Press ‘d’ to change to that directory, ‘c’ to cancel.

scd expects its lookup table to be in ENV:SCD/Table unless told otherwise by the variable scdtable. The easiest way to create the table is with find or list:

    1> FIND dh0: TYPE DIR PRINT > ENVARC:SCD/Table
    1> FIND dh1: TYPE DIR PRINT >> ENVARC:SCD/Table
    1> LIST dh0: DIRS LFORMAT %s%s ALL TO ENVARC:SCD/Table

If the variable scdcommand is set to the name of a command—or the empty string if you want to use the implicit cd feature of the shell—scd will attempt to queue it for execution rather than use its own change directory code. It is recommended that you use this method if you use WShell (set scdcommand to cd or pushcd). In order for this to work the dos handler associated with the stdin stream must support the action queue command. As of release 2.04 Commodore’s con: handler does that.

If queueing is used in a script the result may not be what you expect.

SEE ALSO

cd, find, list

Split(V37)  (Torsten’s AmigaDOS Shell Commands)  Split(V37)

FORMAT

SPLIT [[FROM] file] [TO name] [LINES|BYTES|PARTS n] [PROMPT]

TEMPLATE

FROM,TO/K,LINES/K/N,BYTES/K/N,PARTS/K/N,PROMPT/S

PURPOSE

To split a file into pieces.

SPECIFICATION

split reads file and writes it onto a set of output files. The name of the first output file is name with aa appended, and so on lexicographically, up to zz (a maximum of 676 files). If no name is given, x is default. The lines argument results in n-line pieces, the bytes argument in n-byte pieces, and the parts argument splits the input file into n parts. Only one of the arguments lines, bytes, and parts may be given. If none of them are given, split will default to 1000-line pieces. If the prompt switch is specified, the user will be prompted before each output file is written, to make it possible to change disks. If no input file is given then the default input is used making it possible to use split as the end of a pipe-line. It is unwise to use the parts switch when reading from a pipe.

EXAMPLE

If the file ‘myfile’ is split up with a command like this:

    1> SPLIT myfile TO splitfile.

it can be assembled again with the following command:

    1> CONCAT splitfile.?? TO newfile SORT

BUGS

Does not check to see if there is room for the appended letters in the file part of name. The length of the file part should not exceed 28 characters for ofs and ffs (and a lot less for the ms-dos file system, sigh!).

Split(V37)  (Torsten’s AmigaDOS Shell Commands)  Split(V37)

SEE ALSO

concat, join, type

SplitName(V37)  (Torsten’s AmigaDOS Shell Commands)  SplitName(V37)

FORMAT

SPLITNAME [NAME] name [[PATH] var] [[BASE] var] [[EXT|EXTENSION] var]

TEMPLATE

NAME/A,PATH,BASE,EXT=EXTENSION

PURPOSE

To split a filename into its components.

SPECIFICATION

splitname splits name into its components and stores the results in the local variables specified by the options path, base, and extension. The name foo/bar.baz.qux will be split into “foo/”, “bar.baz”, and “.qux”. If you want to strip .baz too, you must do something like

    1> SPLITNAME foo/bar.baz.qux BASE mybase EXT myext
    1> SPLITNAME $mybase BASE mybase

SEE ALSO

set, unset

Tee(V37)  (Torsten’s AmigaDOS Shell Commands)  Tee(V37)

FORMAT

TEE [[TO] {file}] [APPEND]

TEMPLATE

TO/M,APPEND/S

PURPOSE

Tee is a pipe fitting.

SPECIFICATION

tee transcribes the default input to the default output and makes copies in the files specified by the to option. The append switch causes the output to be appended to the files rather than overwriting them.

TestBits(V37)  (Torsten’s AmigaDOS Shell Commands)  TestBits(V37)

FORMAT

TESTBITS [NAME] file|directory [FLAGS] flags

TEMPLATE

NAME/A,FLAGS/A

PURPOSE

To test whether one or more protection flags are set.

SPECIFICATION

testbits is used to to test the state of one or more of the protection bits. This can be useful in scripts. The protection bits are represented by letters:

r The file can be read. w The file can be written to. e The file is an executable program. d The file can be deleted. s The file is a script. p The file can be made resident. a The file has been archived.

If a letter is preceded by a ‘-’, it means that in order to match, the corresponding file bit must not be set. Whitespace is not allowed between the letters representing the bits. If the state of all the bits given in the flags argument match the file’s protection bits, testbits sets the condition flag to 5 (WARN), otherwise it is set to 0. To check the response, an if statement can be used.

EXAMPLE

    .KEY myfile/A
    TESTBITS <myfile> s
    IF WARN
      ECHO <myfile> is a script
    ELSE
      ECHO <myfile> is not a script
    ENDIF

SEE ALSO

if, protect

TimeCom(V37)  (Torsten’s AmigaDOS Shell Commands)  TimeCom(V37)

FORMAT

TIMECOM [ON|TO log file [APPEND]] [COMMAND] command line

TEMPLATE

ON=TO/K,APPEND/S,COMMAND/F/A

PURPOSE

To time a command.

SPECIFICATION

The command line is executed; after it is complete, timecom prints the elapsed time during the command. The time is reported in seconds. The time is printed on CONSOLE: unless the to option is used to specify an output file. The append switch adds the output to the end of the specified output file. This is useful for keeping a log of the execution times of several commands.

EXAMPLES

    1> TIMECOM MyProgram
    Elapsed time: 23 seconds.
    1> TIMECOM TO timelog APPEND MyProgram
    1> TYPE timelog
    Elapsed time: 23 seconds. Command: MyProgram

BUGS

The time value is not extremely accurate.

SEE ALSO

intuition.library/CurrentTime() in “ROM Kernel Reference Manual: Includes and Autodocs.”

UNIX EQUIVALENT

The inspiration for timecom came from the much more powerful unix command timex(AS CMD)

Unique(V37)  (Torsten’s AmigaDOS Shell Commands)  Unique(V37)

FORMAT

UNIQUE [[FROM] file] [[TO] file] [REPEATED] [UNIQUE|ONCE] [COUNT]

TEMPLATE

FROM,TO,REPEATED/S,UNIQUE=ONCE/S,COUNT/S

PURPOSE

To report repeated lines in a file.

SPECIFICATION

The command unique reads the from file comparing adjacent lines. In the normal case, the second and succeeding copies of repeated lines are removed; the remainder is written on the to file. Note that repeated lines must be adjacent to be found (see sort). If the once switch is used, just the lines that are not repeated in the original file are output. The repeated switch specifies that one copy of just the repeated lines is to be written. The normal mode ouput is the union of the once and repeated mode outputs. The synonym unique for once is kept in this release for compatibility with older versions. The count switch generates an output report with each line preceeded by a count of the number of times it occured. If no from file is given input is read from the default input; likewise if no to file is given output is written to the default output.

SEE ALSO

common, count, sort

BUGS

Unique will fail to function correctly given input lines longer than 512 characters.

UNIX EQUIVALENT

uniq(BU CMD)

Usage(V37)  (Torsten’s AmigaDOS Shell Commands)  Usage(V37)

FORMAT

USAGE [[DIR] {directory}] [BRIEF] [NOHEAD] [NOTOTAL]

TEMPLATE

DIR/M,BRIEF/S,NOHEAD/S,NOTOTAL/S

PURPOSE

To estimate disk space usage.

SPECIFICATION

The command usage gives an estimate, in blocks, of the disk space occupied by the directories given on the command line. Sub-directories are traversed recursively. If no directory is specified, the current directory is used. The total number of bytes stored in all the files contained in the directories are reported as well.

The brief switch causes only the total, for each of the specified directories, to be given. The nohead switch suppresses the printing of the headline. If more than one directory is given, the grand total will be printed as the bottom line, unless suppressed by the nototal switch.

Hard links to other files or directories in the specified directories, will cause them to be counted more than once. This may lead to an incorrectly high estimate. Soft links are completely ignored for now.